import { getBaseUrl } from '@/services/urlconst';
import { getCompanyID, getPosIDs, getUserDepID, getUserID, requestFunComponFiex, requestFunHtml } from '@/utils';
import { useRequest } from 'umi';
const baseUrl = getBaseUrl();

/**
 * 批量导入接口
 * */
export const batchImportServices = (batchImportUrl, batchReqHeader) => {
  const request = useRequest(
    (param) => {
      let payload = {
        importList: [...param],
        createrID: getUserID(),
        createPositionID: getPosIDs(),
        createDepartmentID: getUserDepID(),
        createCompanyID: getCompanyID(),
      };
      let reqUrl = `${baseUrl}${batchImportUrl}`;
      return requestFunComponFiex('POST', reqUrl, payload, { ...batchReqHeader });
    },
    {
      manual: true,
    },
  );

  return {
    batchImportRun: request?.run,
    batchImportLoading: request?.loading,
  };
};
